#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include"global.h"
find(){
	CI *p;
	char key='\0',tosear[20],t[20]={0};
	int length,i=0;
	p=head;
	while('T'!=key&&'N'!=key){
		printf("\nN  :search by Name\nT  :search by Telephone\nB  :Back\n");
		scanf("%c",&key);getchar();
		if('N'==key){
			printf("\nenter the part of the name:");
			scanf("%s",tosear);getchar();
			length=strlen(tosear);
		//	printf("\n***************************\n");
			while(p!=NULL){
				i=0;
			//	printf("\n***************************\n");
				while(*(p->name+i)!='\0'){
				//	printf("\n***************************\n");
					strncpy(t,p->name+i,length);
					if(strcmp(tosear,t)==0){
						printf("\n%-16s%-16s%-8c%-8d%-8s\n",p->name,p->telphone,p->sex,p->age,p->phone);
						break;
					}
					i++;
				}
				p=p->next;
			}
		}
		else if('T'==key){
			printf("\nenter the part of the tel:");
			scanf("%s",tosear);getchar();
			length=strlen(tosear);
			while(p!=NULL){
				i=0;
				while(*(p->telphone+i)!='\0'){
					strncpy(t,p->telphone+i,length);
					if(strcmp(tosear,t)==0){
						printf("\n%-16s%-16s%-8c%-8d%-8s\n",p->name,p->telphone,p->sex,p->age,p->phone);
						break;
					}
					i++;
				}
				p=p->next;
			}
		}
		else if('B'==key)
			return(0);
		else
			printf("\nNo such selection!\n");
	}
}

